package com.agent.auth.entity;

import com.agent.common.constant.CommonConstants;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 用户会话实体
 * @author Jeff_Wan
 * @description 管理用户登录会话信息
 */
@Data
@TableName("user_session")
public class UserSession {
    /**
     * 雪花ID主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    /**
     * 用户ID
     */
    private Long userId;
    /**
     * 会话令牌
     */
    private String sessionToken;
    /**
     * 刷新令牌
     */
    private String refreshToken;
    /**
     * 访问令牌过期时间(UTC)
     */
    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_UTC, timezone = CommonConstants.TIME_ZONE_UTC)
    private LocalDateTime expiresAt;
    /**
     * 刷新令牌过期时间
     */
    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_UTC, timezone = CommonConstants.TIME_ZONE_UTC)
    private LocalDateTime refreshExpiresAt;
    /**
     * 创建时间 (UTC格式)
     */
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_UTC, timezone = CommonConstants.TIME_ZONE_UTC)
    private LocalDateTime createdAt;
    /**
     * 最后访问时间
     */
    @JsonFormat(pattern = CommonConstants.DATE_FORMAT_UTC, timezone = CommonConstants.TIME_ZONE_UTC)
    private LocalDateTime lastAccessedAt;
    /**
     * 设备信息
     */
    private String deviceInfo;
    /**
     * 会话是否激活(1:是,0:否)
     */
    private Boolean isActive;
}